package com.test.action;

import java.util.Iterator;
import java.util.Map;
import java.util.Set;

import com.opensymphony.xwork2.ActionSupport;
import com.test.bean.User;
import com.test.service.UserService;

public class SaveUserAction extends ActionSupport {
	private User user;
	private UserService service;

	public UserService getService() {
		return service;
	}

	public void setService(UserService service) {
		this.service = service;
	}

	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	@Override
	public String execute() throws Exception {
		this.service.Save(this.user);
		return SUCCESS;
	}

	@SuppressWarnings("rawtypes")
	@Override
	public void validate() {
	
		Map map = this.getFieldErrors();
		Set set = map.keySet();
		for(Iterator iter=set.iterator();iter.hasNext();){
			System.out.println(map.get(iter.next()));
		}
		}
		
	}
